export function sleep (interval) {
  return new Promise(resolve => {
    setTimeout(resolve, interval);
  });
}

export function confirmLater (promise, onConfirmCallback) {
  return new Promise((resolve, reject) => {
    promise.on('transactionHash', resolve);
    promise.on('error', reject);
    function onConfirm (confNumber, receipt) {
      promise.off('confirmation', onConfirm);
      onConfirmCallback && onConfirmCallback();
    }
    promise.on('confirmation', onConfirm);
  });
}
